package com.yu8home.schedule;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@EnableAsync
public class ScheduledT {
    private static final Logger log = LoggerFactory.getLogger(ScheduledT.class);

    // 日志前缀：异步会额外开启线程
    @Async
    @Scheduled(fixedRate = 6000)
    public void a() {
        log.info("xxxx：{}", Thread.currentThread().getName());
    }

    // @Async
    @Scheduled(cron = "*/6 * * * * ?")
    public void b() {
        log.info("yyyy：{}", Thread.currentThread().getName());
    }

}
